#pragma once

#include "CMILMatrix.h"
#include "CMILMatrix4x4.h"
#include "HWClip.h"

class CPerspectiveTransformer;

class TransformAndClipFrame
{

public: 
	TransformAndClipFrame();
	virtual ~TransformAndClipFrame();
private: 
	void PrependTransform(const CMILMatrix & transform);
	HRESULT IntersectLocalSpaceClip(HWClip * pClip);
	void SetProjection(const CMILMatrix4x4 * pProjection, CPerspectiveTransformer * pProjectionTransformer);
	void Reset();
	HRESULT Set(const TransformAndClipFrame * pOther);
	void SetTransformAndProjection(const TransformAndClipFrame * pOther);
	HRESULT Prepend(const TransformAndClipFrame * pOther);
	XBOOL Equals(const TransformAndClipFrame & other);
	HRESULT TransformPrimitiveAndCheckOptimizedClipping(HWClip * pLocalSpaceShape, XBOOL isTopFrame, XBOOL isTiledPrimitive, XBOOL * pWasClipped, XBOOL * pCanClipBeOptimized, struct XRECTF_WH * pOptimizedClipRect, const struct XRECTF_WH * pBackBufferSize);
	HRESULT TransformAndClip(XUINT32 originalPointCount, struct PointWithAAMasks * pOriginalPoints, XUINT32 * pTransformedAndClippedPointCount, struct PointWithAAMasks * * ppTransformedAndClippedPoints);
	HRESULT TransformToLocalSpace(HWClip *);
	void TransformToLocalSpace(XUINT32 pointCount, struct XPOINTF4 * pPoints, XBOOL * pIsInvertible);
	void GetProjectionWithoutZ(CMILMatrix4x4 * pProjectionTransform);
	void PrependNetTransformTo(CMILMatrix4x4 * pCombinedTransform);
	void Get2DTransform(CMILMatrix * p2DTransform);
	void Set2DTransform(const CMILMatrix & transform);
	XBOOL IsNextFrameSamePlane(const TransformAndClipFrame * pRedirectedFrame);
	void MergeRedirectionTransforms(const TransformAndClipFrame * pRedirectedFrame);
	XBOOL HasInfiniteClip();
	XBOOL HasZeroSizedClip();
	XBOOL HasProjection();
	CMILMatrix m_2DTransform;  
	xshared_ptr<CMILMatrix4x4 const > m_p3DTransform;  
	CPerspectiveTransformer * m_pProjectionTransformer;
	HWClip m_clip;  
};